Efficient Implementation of First-class Polymorphic Methods in Java
نویسنده
چکیده
This thesis describes a new implementation architecture for polymorphic methods in Generic Java using the NextGen compiler framework. The standard Generic Java (Java 1.5) compiler erases generic types at compilation. This transformation prohibits type-dependent operations, limiting generic expressivity. Type erasure causes unchecked warnings at compilation, and unexpected behavior or exceptions at runtime. Alternative reflection-based implementations of Generic Java support typedependent operations at the cost of significant execution overhead. In contrast, this work presents an efficient implementation of polymorphic methods using NextGen. An extended NextGen compiler generates snippet environment template classes to encode type-dependent operations for polymorphic methods. A customized classloader generates specialized template instantiations on demand. This demand-driven code specialization provides an efficient mechanism to propagate runtime type information, while maintaining backwards compatibility with existing libraries and Java Virtual Machines. Benchmarks show runtime support for polymorphic methods in NextGen outperforms reflection-based approaches, with runtime overhead comparable to erasure-based Generic Java.
منابع مشابه
Efficient Implementation of Run-time Generic Types for Java
We describe an efficient compiler and run-time system for NextGen, a compatible extension of the Java programming language supporting run-time generic types designed by Cartwright and Steele. The resulting system is comparable in performance with both standard Java and the GJ extension of Java, which does not support run-time generic types. Our implementation of NextGen consists of a compiler e...
متن کاملPrecise Inference of Polymorphic Constrained Types
This paper develops a precise polymorphic type inference algorithm. Several methods for polymorphic type inference have been developed, including let-polymorphism and flow-based approaches such as Agesen’s Cartesian Product Algorithm (CPA). In this paper we focus on the flow-based variety. There is a class of polymorphic behavior which CPA misses: so-called data polymorphism. In the context of ...
متن کاملA Recipe for Raw Types
The design of GJ (Bracha, Odersky, Stoutamire and Wadler), an extension of Java with parametric polymorphism, was significantly affected by the issue of compatibility between legacy Java code and new GJ code. In particular, the introduction of raw types made it easier to interface polymorphic code with monomorphic code. In GJ, for example, a polymorphic class List, parameterized by the eleme...
متن کاملType inference for polymorphic methods in Java-like languages
In mainstream class-based object-oriented languages with nominal types, like C++, Java and C#, typechecking algorithms require methods to be annotated with their parameter types, which are either fixed or constrained by a (nominal) bound. On the contrary, languages like ML, CaML and Haskell use powerful type inference algorithms capable of calculating the type for a function in which parameter ...
متن کاملsplitSVM: Fast, Space-Efficient, non-Heuristic, Polynomial Kernel Computation for NLP Applications
We present a fast, space efficient and nonheuristic method for calculating the decision function of polynomial kernel classifiers for NLP applications. We apply the method to the MaltParser system, resulting in a Java parser that parses over 50 sentences per second on modest hardware without loss of accuracy (a 30 time speedup over existing methods). The method implementation is available as th...
متن کامل